import {reactive, ref, watch} from "vue";
import useApi, {type SysUser} from "@/views/sys/api/SysUserApi";
import {useQueryTable} from "@/core/common/hooks/TableHooks";

/**
 * @Author: wangjian
 * 656876071@qq.com
 * @Date: 2024-08-12 16:05:34
 * @LastEditTime: 2024-09-20 09:54:01
 * @FilePath: src/views/sys/user/Hooks.ts
 * @Description:
 */
export const useEntrance = () => {

    const params = reactive<object>({})

    const columns: Array<any> = [
        {
            title: '用户id',
            dataIndex: 'userId'
        },
        {
            title: '登录名',
            dataIndex: 'loginName'
        },
        {
            title: '系统内昵称',
            dataIndex: 'nickName'
        },
        {
            title: '手机号',
            dataIndex: 'phone'
        },
        {
            title: '部门',
            dataIndex: 'deptId'
        },
        {
            title: '职位',
            dataIndex: 'jobId'
        },
        {
            title: '启用、冻结、注销',
            dataIndex: 'status'
        },
        {
            title: '备注信息',
            dataIndex: 'remark'
        },
        {
            title: '创建时间',
            dataIndex: 'createdTime'
        },
        {
            title: '操作',
            dataIndex:'operate'
        }
    ]
    const {getPage, deleteById} = useApi()

    const queryTable = useQueryTable(getPage, deleteById, params)

    return {
        params,
        columns,
        ...queryTable
    }
}
import {useSimpleForm} from "@/core/common/hooks/FormHooks";
import {type SysMenuTree} from "@/views/sys/api/SysMenuApi";

export const useForm = (callback: Function) => {
    const {add, update, getById} = useApi()
    const PRIMARY_KEY = "userId"

    const form = ref<SysUser>({})

    const simpleForm = useSimpleForm(form, PRIMARY_KEY, add, update, getById, callback)



    return {
        form,
        ...simpleForm,
    }
}